﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using iLangl.Model;

namespace iLangl.Tests.SerializationFixture
{
	[TestClass]
	public class CompanyValidationTest : BaseTest
	{
		[TestMethod]
		public void CompanyValidation()
		{
			Company company = GetCompany();

			CompanyRequestContext requestContext = new CompanyRequestContext();

			requestContext.SetContext(company);
			string serializedcompany = requestContext.GetContext().ToString();

			CompanyResponseContext responecontext = new CompanyResponseContext();
			responecontext.SetContext(serializedcompany);

			Company company2 = (Company)responecontext.GetContext();
			requestContext.SetContext(company2);
			string serializedcompany2 = requestContext.GetContext().ToString();

			Assert.AreEqual(serializedcompany, serializedcompany2);
		}

		public static Company GetCompany()
		{
			Company result = new Company();

			result.Address = "Test Address";
			result.City = "Donetsk";
			result.Country = "Ukraine";
			result.Currency = "EUR";
			result.Id = TestSettings.TestCompanyId;
			result.Name = TestSettings.TestCompanyName;
			result.Phone = "(834)xxx-xxx-xx";
			result.State = "No State";
			result.Zip = "840130";

			result.BillingInfo = new BillingInfo();

			result.BillingInfo.Id = TestSettings.TestBillingId;
			result.BillingInfo.BillingCity = "Copenhagen";
			result.BillingInfo.BillingCountry = "Denmark";
			result.BillingInfo.BillingCurrency = "EUR";
			result.BillingInfo.BillingEmail = "test@billing.info";
			result.BillingInfo.BillingFirstName = "Don";
			result.BillingInfo.BillingLastName ="Jhow";
			result.BillingInfo.BillingPostalCode = "123435";
			result.BillingInfo.BillingStreetAddress = "st. Joan Cans b.124, 454 room";
			result.BillingInfo.BillingStreetAddress2 = "sq Saint Pit, 12 b. Reception";
			result.BillingInfo.Company = result;
			result.BillingInfo.Name = "Test Billing Address";
			

			return result;
		}

	}
}
